<? include "../connect.php"; ?>
<?php

ob_start();
session_start();
date_default_timezone_set('Asia/Bangkok');
//$emp_id=$_GET['emp_id'];
$alt_Id = $_GET['alt_Id'];

include "../connect.php";
$strSQL = "SELECT * ,altcomservice.* FROM `altcomservice` LEFT JOIN depart ON altcomservice.de_id = depart.id                                                                                
                                         LEFT JOIN employee ON altcomservice.emp_id = employee.emp_id                                       
                                         LEFT JOIN comname ON altcomservice.cn_id = comname.cn_id
                                         LEFT JOIN userlog  ON altcomservice.id_member = userlog.id_member
                                         lEFT JOIN mtncomservice ON altcomservice.alt_Id = mtncomservice.alt_Id
                                         LEFT JOIN rstcomservice ON altcomservice.alt_ID = rstcomservice.alt_ID
                                         LEFT  JOIN product_detail ON comname.cn_number =  product_detail.pd_id
                                         WHERE altcomservice.alt_Id = '$alt_Id' ";
$objQuery = mysql_query($strSQL);


mysql_query("set NAMES'TIS620'");
$resultData = array();


for ($i = 0; $i < mysql_num_rows($objQuery); $i++) {
    $result = mysql_fetch_array($objQuery);
    array_push($resultData, $result);
}

$altDate = $result[alt_Date];
$altTime = $result[alt_Time];
$txtDatet = date('d/m/Y', strtotime($altDate));
$txtTime = date('H:i', strtotime($altTime));

//Date Maintennace
$matDate = $result[mtn_date];
if ($matDate != NULL) {
    $txtDate = date('d/m/y', strtotime($matDate));
} else {
    $txtDate = NULL;
}

$matTime = $result[mtn_time];
if ($matTime != NULL) {
    $txtTime = date('H:i', strtotime($matTime));
} else {
    $txtTime = NULL;
}

//Date Result IT
$rstDateIt = $result[rst_sentDate];
if ($rstDateIt != NULL) {
    $txtDateRstIT = date('d/m/y', strtotime($rstDateIt));
} else {
    $txtDateRstIT = NULL;
}
$rstTimeIt = $result[rst_sentTime];
if ($rstTimeIt != NULL) {
    $txtTimeRstIt = date('H:i', strtotime($rstTimeIt));
} else {
    $txtTimeRstIt = NULL;
}

//Date Result EMP
$rstDate = $result[rst_inDate];
if ($rstDate != NULL) {
    $txtDateRst = date('d/m/y', strtotime($rstDate));
} else {
    $txtDateRst = NULL;
}
$rstTime = $result[rst_inTime];
if ($rstTime != NULL) {
    $txtTimeRst = date('H:i', strtotime($rstTime));
} else {
    $txtTimeRst = NULL;
}

require('fpdf.php');
define('FPDF_FONTPATH', 'font/');

//$test = $_GET['emp_id'];
class PDF extends FPDF {

    function conv($string) {
        return iconv('UTF-8', 'TIS-620', $string);
    }

    function Header() {
        $this->SetMargins(15, 20, 10);
        $this->AddFont('angsa', '', 'angsa.php');
        $this->AddFont('angsana', 'B', 'angsab.php');
        $this->SetFont('angsa', 'U', 12);
        $this->Cell(195, 7, iconv('UTF-8', 'TIS-620', "F-IT-005 R03"), 0, 1, "R");
        $this->SetFont('angsa', '', 12);
        $this->SetFillColor(194, 194, 194);
        $this->SetFont('angsana', 'B', 12);
        $this->Cell(190, 7, iconv('UTF-8', 'TIS-620', "ใบแจ้งซ่อมคอมพิวเตอร์-โปรแกรมและอุปกรณ์ต่อพ่วง"), 0, 1, "C", true);
        $this->Ln(2);
        $this->SetFont('angsa', '', 12);
        $this->Cell(15, 7, iconv('UTF-8', 'TIS-620', "ผู้แจ้งซ่อม : "), 0, 0, "R");
        $this->Cell(25, 7, iconv('UTF-8', 'TIS-620', "..............................."), 0, 0, "C");
        $this->Cell(10, 7, iconv('UTF-8', 'TIS-620', "แผนก :"), 0, 0, "R");
        $this->Cell(12, 7, iconv('UTF-8', 'TIS-620', "...................................."), 0, 0, "L");
        $this->Cell(22, 7, iconv('UTF-8', 'TIS-620', "วันที่"), 0, 0, "R");
        $this->Cell(9, 7, iconv('UTF-8', 'TIS-620', ".................."), 0, 0, "L");
        $this->Cell(17, 7, iconv('UTF-8', 'TIS-620', "เวลาแจ้ง"), 0, 0, "R");
        $this->Cell(9, 7, iconv('UTF-8', 'TIS-620', "............"), 0, 0, "L");
        $this->Cell(27, 7, iconv('UTF-8', 'TIS-620', "รหัสเครื่องที่แจ้งซ่อม"), 0, 0, "R");
        $this->Cell(20, 7, iconv('UTF-8', 'TIS-620', ".............................."), 0, 0, "L");
        $this->Cell(10, 7, iconv('UTF-8', 'TIS-620', "เลขที่"), 0, 0, "R");
        $this->Cell(10, 7, iconv('UTF-8', 'TIS-620', "............."), 0, 1, "L");
//        $this->Image('../images/checkbox.png', 25, 35, 3);
        $this->Cell(40, 7, iconv('UTF-8', 'TIS-620', "โปรแกรม"), 0, 0, "C");
//        $this->Image('../images/checkbox.png', 82, 35, 3);
        $this->Cell(100, 7, iconv('UTF-8', 'TIS-620', "อุปกรณ์ต่อพ่วงและคอมพิวเตอร์"), 0, 1, "C");
        $this->Cell(13, 7, iconv('UTF-8', 'TIS-620', "อาการเสีย :"), 0, 0, "C");
        $this->Cell(149, 7, iconv('UTF-8', 'TIS-620', "..........................................................................................................................................................................................................................................."), 0, 1, "L");
    }

}

$pdf = new PDF();
//*** Load MySQL Data ***//
//************************//
$pdf->AddPage('P', 'A4');
$pdf->SetMargins(15, 20, 12);
$pdf->SetAutoPageBreak(true, 5);
$pdf->SetFont('angsana', 'BU', 12);
$pdf->SetLineWidth(0.6);

$pdf->Cell(110, 7, iconv('UTF-8', 'TIS-620', 'ดำเนินการซ่อมโดยฝ่ายเทคโนโลยีสารสนเทศ'), 1, 0, 'L');

$pdf->Cell(80, 7, iconv('UTF-8', 'TIS-620', 'ผลการซ่อมและส่งมอบ'), 1, 1, 'L');
$pdf->SetFont('angsa', '', 10);
$pdf->Text(32, 30, iconv('UTF-8', 'TIS-620', $result['emp_nameTh']));
$pdf->Text(67, 30, iconv('UTF-8', 'TIS-620', $result['departname']));
$pdf->Text(102, 30, iconv('UTF-8', 'TIS-620', $txtDatet));
$pdf->Text(128, 30, iconv('UTF-8', 'TIS-620', $txtTime));
$pdf->Text(165, 30, iconv('UTF-8', 'TIS-620', $result['pd_name']));
$pdf->Text(195, 30, iconv('UTF-8', 'TIS-620', $result['alt_Num']));
$pdf->Text(32, 44, iconv('UTF-8', 'TIS-620', $result['alt_Error']));
$pdf->Text(40, 87, iconv('UTF-8', 'TIS-620', $result['mtn_detail']));
$pdf->Text(40, 111, iconv('UTF-8', 'TIS-620', $txtDate));
$pdf->Text(80, 111, iconv('UTF-8', 'TIS-620', $txtTime));
$pdf->Text(70, 117, iconv('UTF-8', 'TIS-620', $result['f_name']));
$pdf->Text(150, 69, iconv('UTF-8', 'TIS-620', $result['rst_detail']));
$pdf->Text(170, 100, iconv('UTF-8', 'TIS-620', $result['f_name']));
$pdf->Text(145, 105, iconv('UTF-8', 'TIS-620', $txtDateRstIT));
$pdf->Text(185, 105, iconv('UTF-8', 'TIS-620', $txtTimeRstIt));
$pdf->Text(150, 112, iconv('UTF-8', 'TIS-620', $result['emp_nameTh']));
$pdf->Text(145, 118, iconv('UTF-8', 'TIS-620', $txtDateRst));
$pdf->Text(185, 118, iconv('UTF-8', 'TIS-620', $txtTimeRst));



$pdf->SetFont('angsa', '', 12);
$rsCanService = $result['mtn_can'];
if ($rsCanService == "CanService") {
    $pdf->Image('../images/checkboxtrueblack.png', 18, 55, 5);
} else {
    $pdf->Image('../images/checkbox.png', 18, 55, 3);
}
$pdf->Cell(110, 6, iconv('UTF-8', 'TIS-620', '          สามารถซ่อมได้'), 'LR', 0, 'L');

$pdf->SetFont('angsa', '', 12);
$rstNotCan = $result['rst_notCan'];
if ($rstNotCan == "CanService") {
    $pdf->Image('../images/checkboxtrueblack.png', 127, 55, 5);
} else {
    $pdf->Image('../images/checkbox.png', 127, 55, 3);
}
$pdf->Cell(80, 6, iconv('UTF-8', 'TIS-620', '        สามารถใช้งานได้ตามปกติ'), 'LR', 1, 'L');

$pdf->SetFont('angsa', '', 12);
$rsChgDevice = $result['mtn_chgDevice'];
if ($rsChgDevice == "ChangDevice") {
    $pdf->Image('../images/checkboxtrueblack.png', 55, 61, 5);
} else {
    $pdf->Image('../images/checkbox.png', 55, 61, 3);
}
$pdf->Cell(110, 6, iconv('UTF-8', 'TIS-620', '     มีการเปลี่ยนอุปกรณ์'), 'LR', 0, 'C');


$pdf->SetFont('angsa', '', 12);
$rsNotCan = $result['rst_notCan'];
if ($rsNotCan == "NotCan") {
    $pdf->Image('../images/checkboxtrueblack.png', 127, 61, 5);
} else {
    $pdf->Image('../images/checkbox.png', 127, 61, 3);
}
$pdf->Cell(80, 6, iconv('UTF-8', 'TIS-620', '        ไม่สามารถใช้งานได้ตามปกติ'), 'LR', 1, 'L');


$pdf->SetFont('angsa', '', 12);
$rsNotDevice = $result['mtn_notDevice'];
if ($rsNotDevice == "NotDevice") {
    $pdf->Image('../images/checkboxtrueblack.png', 55, 67, 5);
} else {
    $pdf->Image('../images/checkbox.png', 55, 67, 3);
}
$pdf->Cell(110, 6, iconv('UTF-8', 'TIS-620', '         ไม่มีการเปลี่ยนอุปกรณ์'), 'LR', 0, 'C');


$pdf->Cell(80, 6, iconv('UTF-8', 'TIS-620', 'รายละเอียดการซ่อม..........................................................................'), 'LR', 1, 'L');

$pdf->SetFont('angsa', '', 12);
$rsNewProgram = $result['mtn_newProgram'];
if ($rsNewProgram == "NewProgram") {
    $pdf->Image('../images/checkboxtrueblack.png', 55, 73, 5);
} else {
    $pdf->Image('../images/checkbox.png', 55, 73, 3);
}
$pdf->Cell(110, 6, iconv('UTF-8', 'TIS-620', '         มีการลงโปรแกรมใหม่'), 'LR', 0, 'C');

$pdf->Cell(80, 6, iconv('UTF-8', 'TIS-620', '..........................................................................................................'), 'LR', 1, 'L');


$pdf->SetFont('angsa', '', 12);
$rsEditProgram = $result['mtn_editProgram'];
if ($rsEditProgram == "EditProgram") {
    $pdf->Image('../images/checkboxtrueblack.png', 55, 79, 5);
} else {
    $pdf->Image('../images/checkbox.png', 55, 79, 3);
}
$pdf->Cell(110, 6, iconv('UTF-8', 'TIS-620', '       มีการแก้ไขโปรแกรม'), 'LR', 0, 'C');


$pdf->SetFont('angsa', '', 12);
$rsProgram = $result['alt_Program'];
if ($rsProgram == "Program") {
    $pdf->Image('../images/checkboxtrueblack.png', 25, 35, 5);
} else {
    $pdf->Image('../images/checkbox.png', 25, 35, 3);
}


$pdf->SetFont('angsa', '', 12);
$rsDevice = $result['alt_Device'];
if ($rsDevice == "Device") {
    $pdf->Image('../images/checkboxtrueblack.png', 82, 35, 5);
} else {
    $pdf->Image('../images/checkbox.png', 82, 35, 3);
}


$pdf->Cell(80, 6, iconv('UTF-8', 'TIS-620', '..........................................................................................................'), 'LR', 1, 'L');

$pdf->Cell(110, 6, iconv('UTF-8', 'TIS-620', 'รายละเอียดการซ่อม................................................................................................................'), 'LR', 0, 'L');
$pdf->Cell(80, 6, iconv('UTF-8', 'TIS-620', '..........................................................................................................'), 'LR', 1, 'L');

$pdf->Cell(110, 6, iconv('UTF-8', 'TIS-620', '................................................................................................................................................'), 'LR', 0, 'L');
$pdf->Cell(80, 6, iconv('UTF-8', 'TIS-620', '..........................................................................................................'), 'LR', 1, 'L');

$pdf->Cell(110, 6, iconv('UTF-8', 'TIS-620', '................................................................................................................................................'), 'LR', 0, 'L');
$pdf->SetFont('angsa', 'U', 12);
$pdf->Cell(80, 6, iconv('UTF-8', 'TIS-620', 'เจ้าหน้าที่ฝ่ายเทคโนโลยีสารสนเทศ: ...............................................'), 'LR', 1, 'L');

$pdf->SetFont('angsa', '', 12);
$pdf->Cell(110, 6, iconv('UTF-8', 'TIS-620', '................................................................................................................................................'), 'LR', 0, 'L');
$pdf->Cell(80, 6, iconv('UTF-8', 'TIS-620', '   วันที่ : .......................................................เวลาส่ง : .........................'), 'LR', 1, 'L');

$pdf->Cell(110, 6, iconv('UTF-8', 'TIS-620', '   วันที่ : .......................................................เวลารับ : ...............................'), 'LR', 0, 'L');
$pdf->Cell(80, 6, iconv('UTF-8', 'TIS-620', 'เจ้าหน้าที่ผู้แจ้ง: .....................................................................................'), 'LR', 1, 'L');

$pdf->SetFont('angsa', 'U', 12);
$pdf->Cell(110, 6, iconv('UTF-8', 'TIS-620', 'เจ้าหน้าที่ฝ่ายเทคโนโลยีสารสนเทศ: ......................................................................................'), 'LRB', 0, 'L');
$pdf->SetFont('angsa', '', 12);
$pdf->Cell(80, 6, iconv('UTF-8', 'TIS-620', '   วันที่ : .......................................................เวลารับ : .........................'), 'LRB', 1, 'L');

$pdf->SetFont('angsana', 'B', 12);
$pdf->Cell(190, 7, iconv('UTF-8', 'TIS-620', "ส่งซ่อมภายนอก"), 1, 1, "L");

$pdf->SetFont('angsa', '', 12);
$pdf->Image('../images/checkbox.png', 18, 129, 3);
$pdf->Cell(190, 7, iconv('UTF-8', 'TIS-620', "          ไม่สามารถซ่อมได้ : ..........................................................................................................................................................................................................."), 'LR', 1, "L");
$pdf->Cell(190, 7, iconv('UTF-8', 'TIS-620', '......................................................................................................................................................................................................................................................'), 'LR', 1, 'L');

$pdf->SetFont('angsa', 'U', 12);
$pdf->Cell(190, 7, iconv('UTF-8', 'TIS-620', "เจ้าหน้าที่ฝ่ายเทคโนโลยีสารสนเทศ: ....................................................."), 'LR', 1, "R");

$pdf->SetFont('angsa', '', 12);
$pdf->Cell(190, 7, iconv('UTF-8', 'TIS-620', " วันที่ : .............../................./....................... เวลา : ..............................."), 'LRB', 1, "R");

$pdf->Image('../images/checkbox.png', 18, 157, 3);
$pdf->Cell(190, 7, iconv('UTF-8', 'TIS-620', "          ขออนุมัติซ่อม : ..................................................................................................................................................................................................................."), 'LR', 1, "L");

$pdf->Cell(190, 7, iconv('UTF-8', 'TIS-620', " ......................................................................................................................................................................................................................................................"), 'LR', 1, "L");

$pdf->Image('../images/checkbox.png', 18, 171, 3);
$pdf->Cell(190, 7, iconv('UTF-8', 'TIS-620', "          ไม่ขออนุมัติซ่อม : ..............................................................................................................................................................................................................."), 'LR', 1, "L");

$pdf->Cell(190, 7, iconv('UTF-8', 'TIS-620', " ......................................................................................................................................................................................................................................................"), 'LR', 1, "L");

$pdf->SetFont('angsa', 'U', 12);
$pdf->Cell(190, 6, iconv('UTF-8', 'TIS-620', 'หัวหน้าแผนกเทคโนโลยีสารสนเทศ: ...................................................'), 'LR', 1, 'R');
$pdf->SetFont('angsa', '', 12);
$pdf->Cell(190, 6, iconv('UTF-8', 'TIS-620', ' วันที่ : .............../................./....................... เวลา : ...............................'), 'LRB', 1, 'R');

$pdf->Image('../images/checkbox.png', 18, 197, 3);
$pdf->Cell(190, 7, iconv('UTF-8', 'TIS-620', "          อนุมัติซ่อม : ........................................................................................................................................................................................................................"), 'LR', 1, "L");

$pdf->Cell(190, 7, iconv('UTF-8', 'TIS-620', " ......................................................................................................................................................................................................................................................"), 'LR', 1, "L");

$pdf->Image('../images/checkbox.png', 18, 211, 3);
$pdf->Cell(190, 7, iconv('UTF-8', 'TIS-620', "          ไม่อนุมัติซ่อม : ...................................................................................................................................................................................................................."), 'LR', 1, "L");

$pdf->Cell(190, 7, iconv('UTF-8', 'TIS-620', " ......................................................................................................................................................................................................................................................"), 'LR', 1, "L");

$pdf->SetFont('angsa', 'U', 12);
$pdf->Cell(190, 6, iconv('UTF-8', 'TIS-620', 'ผู้จัดการแผนกฝ่ายเทคโนโลยีสารสนเทศ: ...........................................'), 'LR', 1, 'R');
$pdf->SetFont('angsa', '', 12);
$pdf->Cell(190, 6, iconv('UTF-8', 'TIS-620', ' วันที่ : .............../................./....................... เวลา : ...............................'), 'LRB', 1, 'R');

$pdf->Ln(2);

$pdf->SetFont('angsa', 'U', 12);
$pdf->Cell(190, 6, iconv('UTF-8', 'TIS-620', 'ผลการดำเนินการส่งซ่อมภายนอกและติดตั้ง'), 'TLR', 1, 'L');

$pdf->SetFont('angsa', '', 12);
$pdf->Image('../images/checkbox.png', 25, 245, 3);
$pdf->Cell(60, 7, iconv('UTF-8', 'TIS-620', "สามารถใช้งานได้ตามปกติ"), 'L', 0, "C");
$pdf->Image('../images/checkbox.png', 71, 245, 3);
$pdf->Cell(130, 7, iconv('UTF-8', 'TIS-620', "ไม่สามารถใช้งานได้ตามปกติ"), 'R', 1, "L");

$pdf->Cell(190, 7, iconv('UTF-8', 'TIS-620', "         การดำเนินงาน :  ...................................................................................................................................................................................................................."), 'LR', 1, "L");

$pdf->Cell(190, 7, iconv('UTF-8', 'TIS-620', "........................................................................................................................................................................................................................................................."), 'LR', 1, "L");

$pdf->Cell(110, 6, iconv('UTF-8', 'TIS-620', '     ผู้แจ้งซ่อม : ..........................................................................'), 'L', 0, 'L');
$pdf->SetFont('angsa', 'U', 12);
$pdf->Cell(80, 6, iconv('UTF-8', 'TIS-620', 'เจ้าหน้าที่ฝ่ายเทคโนโลยีสารสนเทศ: .....................................................'), 'R', 1, 'L');

$pdf->SetFont('angsa', '', 12);
$pdf->Cell(110, 6, iconv('UTF-8', 'TIS-620', '   วันที่ : .............../................./.......................เวลา : ...............................'), 'LB', 0, 'L');
$pdf->Cell(80, 6, iconv('UTF-8', 'TIS-620', '   วันที่ : .............../................./.......................เวลา : ...............................'), 'RB', 1, 'L');

$pdf->Output();
?>